<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body>
<div id="app">

  <el-input type="text" style="width: 200px" v-model="emp.name"
            placeholder="姓名"></el-input>
  <el-input type="text" style="width: 200px" v-model="emp.salary"
            placeholder="工资"></el-input>
  <el-input type="text" style="width: 200px" v-model="emp.job"
            placeholder="工作"></el-input>
  <el-button @click="add()">添加</el-button>
  <h3>员工列表</h3>
  <el-table :data="arr">
    <el-table-column type="index" label="编号"></el-table-column>
    <el-table-column prop="name" label="名字"></el-table-column>
    <el-table-column prop="salary" label="工资"></el-table-column>
    <el-table-column prop="job" label="工作"></el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
  let v = new Vue({
    el: '#app',
    data: function() {
      return {
        emp:{name:"",salary:"",job:""},
        arr:[]
      }
    },
    methods:{
      add(){
        v.arr.push({name:v.emp.name,salary:v.emp.salary,job:v.emp.job});
      },
      handleDelete(i,emp){
        if (confirm("您确认删除"+emp.name+"吗?")){
          v.arr.splice(i,1);
          v.$message.success("删除成功!");
        }
      }
    }
  })
</script>
</html>